var regexObj = {
		number:function(value){
			reg=/^([0-9]+)$/;
			return reg.test(value);
		},
		email:function(value){//邮件
			reg=/^\w{3,}@\w+(\.\w+)+$/;
			return reg.test(value);
		},
		mobile:function(value){//手机号
			reg=/^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1})|(14[0-9]{1}))+\d{8})$/;
			return reg.test(value);
		},
		zipcode:function(value){ //邮编
			reg=/^[0-9]{6}$/;
			return reg.test(value);
		},
		chinese:function(value){//仅中文
			reg=/^[\u4e00-\u9fa5]+$/;
			return reg.test(value);
		},
		idcard:function(value){ //身份证
			reg=/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/;
			return reg.test(value);
		},
		url:function(value){ //地址url
			return ture;
		},
		notempty:function(value){ //长度限制
			reg=/^[\u4e00-\u9fa5_a-zA-Z0-9]{1,10}$/;
			return reg.test(value);
			
		},
		ip4:function(value){
			reg=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
			return reg.test(value);
		},
		money:function(value){
			reg=/^[\d]*(.[\d]{1,2})?$/;
			return reg.test(value);
		},
		word:function(value){
			reg=/^[\u4e00-\u9fa5_a-zA-Z0-9]+$/;
			return reg.test(value);
		},
};
var regexMsg = {
		number:"只能输入数字,请重新输入!",
		email :"邮件格式不正确,请重新输入!",
		mobile:"手机号码格式不正确,请重新输入!",
		zipcode:"编码格式不正确,请重新输入!",
		chinese:"只能输入中文字符,请重新输入!",
		idcard :"身份证号码格式不正确,请重新输入!",
		money:"输入金额不正确,请重新输入!",
		notempty:"输入长度不能超过10个字符,请重新输入!",
		word:"不能输入非法字符,请重新输入!",	
};

/**
 * 获取时间戳
 * @returns
 */
function getTimestamp(){
	return new Date().getTime();
}

/**
 * 日期格式化
 */
function dateFormat(sdate){
	var tmpDate ;
	if(sdate == null || sdate.length != 14 ){
		return  "";
	}
	tmpDate = sdate.substring(0,4) + "-";
	tmpDate = tmpDate + sdate.substring(4,  6) + "-";
	tmpDate = tmpDate + sdate.substring(6,  8) + " ";
	tmpDate = tmpDate + sdate.substring(8, 10) + ":";
	tmpDate = tmpDate + sdate.substring(10,12) + ":";
	tmpDate = tmpDate + sdate.substring(12,14) ;

	return tmpDate;
}

function cent2Yuan(cent) { 
	if(cent==null||cent==""||isNaN(cent)){
		return "";
	}
 	return toDecimal2(cent/100);
}  
//保留两位小数
function toDecimal2(x) { 
    var f = parseFloat(x); 
    if (isNaN(f)) { 
      return x; 
    } 
    var f = Math.round(x*100)/100; 
    var s = f.toString(); 
    var rs = s.indexOf('.'); 
    if (rs < 0) { 
      rs = s.length; 
      s += '.'; 
    } 
    while (s.length <= rs + 2) { 
      s += '0'; 
    } 
    return s; 
  } 

function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var seperator2 = ":";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
    return currentdate;
}

function addDate(date,days){ 
	var d=new Date(date); 
	d.setDate(d.getDate()+days); 
	var month=d.getMonth()+1; 
	var day = d.getDate(); 
	if(month<10){ 
		month = "0"+month; 
	} 
	if(day<10){ 
		day = "0"+day; 
	} 
	var val = d.getFullYear()+"-"+month+"-"+day; 
	return val; 
}
